package com.yilong.springcloudalibabanacos.sys.listener;

import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.common.message.MessageExt;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Service;

/**
 * @ProjectName: springcloud-alibaba-yilong
 * @Package: com.yilong.springcloudalibabanacos.sys.listener
 * @ClassName: RocketMQMsgListener
 * @Author: WYL
 * @Description:
 * @Date: 2021/9/4 12:58
 * @Version: 1.0.0
 */
@Slf4j
@Service
@RocketMQMessageListener(topic = "test-topic", consumerGroup = "${rocketmq.producer.group}")
public class RocketMQMsgListener implements RocketMQListener<MessageExt> {

    @Override
    public void onMessage(MessageExt message) {
        byte[] body = message.getBody();
        String msg = new String(body);
        log.info("接收到消息：{}", msg);
    }
}
